package com.joe.lucene.facet.salmonrun;

import java.util.HashMap;
import java.util.Map;
import java.util.Set;

import org.apache.lucene.index.Term;
import org.apache.lucene.search.IndexSearcher;
import org.apache.lucene.search.Query;
import org.apache.lucene.search.TermQuery;

public class FacetedByBitSets {
	private static String index_dir = "F:\\opacindex\\solr\\data\\index";
	
	public static void a() throws Exception{
		  IndexSearcher searcher = new IndexSearcher(index_dir);
		  Query baseQuery = new TermQuery(new Term("marc", "java"));
		  Map<String,Query> subQueries = new HashMap<String,Query>();
		  subQueries.put("f_subject", new TermQuery(new Term("marc", "f_subject")));
		  subQueries.put("f_author", new TermQuery(new Term("marc", "f_author")));
		  subQueries.put("f_pubdate", new TermQuery(new Term("marc", "f_pubdate")));
		  
		  BitSetFacetHitCounter facetHitCounter = new BitSetFacetHitCounter();
		  facetHitCounter.setSearcher(searcher);
		  facetHitCounter.setBaseQuery(baseQuery);
		  facetHitCounter.setSubQueries(subQueries);
		  Map<String,Integer> counts = facetHitCounter.getFacetHitCounts();
		  Set set = counts.keySet();
		  System.out.println("set:\n"+set+"\ncounts:\n"+counts);
	}
	
	/**
	 * @param args
	 * @throws Exception 
	 */
	public static void main(String[] args) throws Exception {
		// TODO Auto-generated method stub
		a();
	}

}
